package com.wongsir.springaop;

import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;

public class LogInterceptor implements InvocationHandler{

	private Object target;
	
	public Object getTarget() {
		return target;
	}

	public void setTarget(Object target) {
		this.target = target;
	}
	
	/**
	 * 切面织入的内容（假设这个是在执行方法前织入）
	 * @param method
	 */
	public void beforeMethod(Method method) {
		System.out.println(method.getName() + " start");
	}

	@Override
	public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
		this.beforeMethod(method);
		method.invoke(target, args);
		return null;
	}

}
